﻿<?php $this->load->view('layout/header'); ?>
<script type="text/javascript" charset="utf-8" src="/static/bk/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/bk/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/bk/ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/bk/ueditor/lang/zh-cn/zh-cn.js"></script>

<script language="javascript" type="text/javascript" src="/static/bk/datepicker/WdatePicker.js"></script>

<form runat="server" action="<?php echo $post_url; ?>" id="form1" method="post">
    <div id="container">
        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="table_form">
            <tr class="table_form_title">
                <td colspan="4">
                    <span id="lblTitle"><?php echo isset($article['articleid'])?'修改':'添加';?></span>文章
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    <span class="star">*</span>语言版本：
                </td>
                <td>
                    <select name="configid" id="configid">
                        <option value="-1">请选择</option>
                        <?php foreach ($config as $k => $v) { ?>
                            <option <?php echo $article['configid'] == $v['configid'] ? 'selected="selected" ' : ''; ?>value="<?php echo $v['configid']; ?>"><?php echo $v['languagever']; ?></option>
                        <?php } ?>
                    </select>
                    <span id="configid_tips" style="color:Red;display:none;">请选择</span>
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    <span class="star">*</span>栏目分类：
                </td>
                <td>
                    <select name="classid" id="classid">
                        <option value="-1">请选择</option>
                        <?php foreach ($classtree as $k => $v) { ?>
                            <option <?php echo $article['classid'] == $k ? 'selected="selected" ' : ''; ?>value="<?php echo $k; ?>"><?php echo $v; ?></option>
                        <?php } ?>
                    </select>
                    <span id="classid_tips" style="color:Red;display:none;">请选择</span>
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    <span class="star">*</span>标题：
                </td>
                <td>
                    <input name="title" type="text" id="title" value="<?php echo $article['title']; ?>" />
                    <span id="title_tips" style="color:Red;display:none;">不能为空</span>
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    作者：
                </td>
                <td>
                    <input name="author" type="text" id="author"  value="<?php echo $article['author']; ?>"/>
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    来源：
                </td>
                <td>
                    <input name="comefrom" type="text" id="comefrom"  value="<?php echo $article['comefrom']; ?>"/>
                </td>
            </tr>
            <tr class="table_form_row" style="display: none;">
                <td style="width: 15%" align="right">
                    小图设置：
                </td>
                <td>
                    <select name="thumbtype" id="thumbtype">
                        <option value="0">手动上传</option>
                        <option value="-1">由大图生成</option>
                        <option value="HW">├指定高宽缩放(可能变形)</option>
                        <option value="W">├指定宽，高按比例</option>
                        <option value="H">├指定高，宽按比例</option>
                        <option value="Cut">├指定高宽裁减(可能变形)</option>
                        <option value="CutScale">├指定高宽并按比例裁减(推荐)</option>a
                    </select>
                </td>
            </tr>
            <tr class="table_form_row" id="trSmallPic">
                <td style="width: 15%" align="right">
                    小图：
                </td>
                <td>
                    <input name="smallpic" type="text" id="smallpic" value="<?php echo $article['smallpic']; ?>" />
                    <input type="button" value="上传图片" onclick="upload_file('smallpic');" />
                    <input type="button" value="选择图片" onclick="selete_file('smallpic');" />
                    <input type="button" value=" 预览 " onclick="preview_file('smallpic');" />
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    大图：
                </td>
                <td>
                    <input name="bigpic" type="text" id="bigpic" value="<?php echo $article['bigpic']; ?>"/>
                    <input type="button" value="上传图片" onclick="upload_file('bigpic');" />
                    <input type="button" value="选择图片" onclick="selete_file('bigpic');" />
                    <input type="button" value=" 预览 " onclick="preview_file('bigpic');" />
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    关键字：
                </td>
                <td>
                    <input name="keywords" type="text" id="keywords" value="<?php echo $article['keywords']; ?>"/>多个关键字请用","分隔
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    简单描述：
                </td>
                <td>
                    <textarea name="description" rows="8" cols="40" id="description"><?php echo $article['description']; ?></textarea>
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    详细内容：
                </td>
                <td>
                    <script id="details" type="text/plain" style="width: 100%; height: 350px;"><?php echo $article['details']; ?></script>
                    <script type="text/javascript">
                        var ue = UE.getEditor('details', {
                            textarea: 'details'
                        });</script>

                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    设置：
                </td>
                <td>
                    <input id="isrecommend" <?php echo $article['isrecommend']==1?'checked="checked" ':'';?>type="checkbox" name="isrecommend" value="1" /><label for="chkIsRecommend">推荐</label>
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    <span class="star">*</span>访问次数：
                </td>
                <td>
                    <input name="clicknum" type="text" num="true" value="<?php echo $article['clicknum']; ?>" id="clicknum" class="input_shadow" />
                    <span id="clicknum_tips" style="color:Red;display:none;">不能为空</span>
                    <span id="clicknum_num_tips" style="color:Red;display:none;">只能为数字</span>
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    <span class="star">*</span>排序号：
                </td>
                <td>
                    <input name="listid" type="text" num="true" value="<?php echo $article['listid']; ?>" id="listid" />
                    <span id="listid_tips" style="color:Red;display:none;">不能为空</span>
                    <span id="listid_num_tips" style="color:Red;display:none;">只能为数字</span>
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    是否关闭：
                </td>
                <td>
                    <span id="radIsClose">
                        <input id="isclose" type="radio" name="isclose" value="1" <?php echo $article['isclose'] == 1 ? 'checked="checked" ' : ''; ?>/>
                        <label for="radIsClose_0">是</label>
                        <input id="radIsClose_1" type="radio" name="isclose" value="0" <?php echo $article['isclose'] == 0 ? 'checked="checked" ' : ''; ?>/>
                        <label for="radIsClose_1">否</label>
                    </span>
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    日期：
                </td>
                <td>
                    <input class="Wdate" name="addtime" readonly="readonly" type="text" onClick="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'})" value="<?php echo $article['addtime']; ?>">
                </td>
            </tr>
            <tr class="table_form_btn">
                <td align="right">
                    <div id="hiddendiv" style="display: none;">
                    </div>
                </td>
                <td colspan="3">
                    <input type="submit" name="btnSave" value="保存" id="btnSave" />
                    <input type="button" name="Submit" value="返回" onclick="javascript:history.go(-1);" />
                    <span id="errMsg" style="color:Red;"></span>
                </td>
            </tr>
        </table>
    </div>

</form>


<script>

    $(".a_config").toggle(function() {
        $(".table_form_classconfig").show();
    }, function() {
        $(".table_form_classconfig").hide();
    });
    var is = true;
    $('#configid,#classid').change(function() {
        if (this.id == 'configid') {
            $.ajax({
                type: "get",
                url: b_url + "/article/get_class?configid=" + this.value,
                dataType: 'html',
                beforeSend:
                        function() {
                        },
                success:
                        function(data) {
                            $('#classid').empty();
                            $("#classid").html(data);
                            /*for (var key in data) {
                                $('#classid').prepend("<option value='" + key + "'>" + data[key] + "</option>");
                            }
                            $("#classid").prepend("<option value='-1' selected='selected' >请选择</option>");*/
                        }
            });
        }
        selete_tips($(this));
    });
    
    $('#title,#clicknum,#listid').change(function() {
        input_tips($(this));
    });

    $('#form1').submit(function() {
        var is = true;
        if (!selete_tips($('#configid'))) {
            is = false;
        }
        if (!selete_tips($('#classid'))) {
            is = false;
        }

        if (!input_tips($('#title'))) {
            is = false;
        }
        if (!input_tips($('#clicknum'))) {
            is = false;
        }
        if (!input_tips($('#listid'))) {
            is = false;
        }
        return is;
    });
    
    $("#thumbtype").change(function() {
        if ($(this).val() == "-1") {
            alert("请选择生成方式");
            $(this).find("option").eq(6).attr("selected", true);
        }
        if ($(this).val() == "0") {
            $("#trSmallPic").show();
        }
        else {
            $("#trSmallPic").hide();
        }
    });
</script>

<?php $this->load->view('layout/footer'); ?>
